#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int n;
map<LL,LL> mymap;
vector<LL> vec;
LL num,c;
LL ans=0;
int main(){
	cin>>n>>c;
	for(int i=0;i<n;i++){
		cin>>num;
		if(mymap.count(num)){
			mymap[num]++;
		}
		else{
			mymap[num]=1;
			vec.emplace_back(num);
		}
	}
	for(auto u:vec){
		LL v=u+c;
		if(mymap.count(v)){
			ans+=mymap[u]*mymap[v];
		}
	}
	cout<<ans;
	return 0;
}
